import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xvideos/assets_tool/images.dart';
import 'package:xvideos/hj_page/main_page/provider/ai_bubble_provider.dart';
import 'package:xvideos/hj_page/mine_business/ai/ai_home_menu_page.dart';
import 'package:provider/provider.dart';

class AIFloatingButton extends StatefulWidget {
  const AIFloatingButton({super.key});

  @override
  State<AIFloatingButton> createState() => _AIFloatingButtonState();
}

class _AIFloatingButtonState extends State<AIFloatingButton> {
  @override
  Widget build(BuildContext context) {
    return Stack(
      clipBehavior: Clip.none,
      children: [
        SizedBox(
          height: 116,
          width: 112,
          child: InkWell(
            onTap: () => Get.to(AiHomeMenuPage()),
            child: Image.asset(
              'dialog.gif'.commonImgPath,
              width: 116,
              height: 112,
              alignment: Alignment.centerRight,
            ),
          ),
        ),
        Consumer<AIBubbleProvider>(builder: (_, bubble, __) {
          if (bubble.bubbleHint.isEmpty) return SizedBox.shrink();
          return Positioned(
            left: -1,
            top: -30,
            child: InkWell(
              onTap: () => Get.to(AiHomeMenuPage()),
              child: Container(
                padding: EdgeInsets.only(top: 16, bottom: 24, left: 12, right: 12),
                decoration: BoxDecoration(
                  image: DecorationImage(
                    image: AssetImage('ai_bubble.png'.mineImgPath),
                  ),
                ),
                child: Text(
                  '${bubble.bubbleHint}',
                  textAlign: TextAlign.center,
                  maxLines: 2,
                  style: TextStyle(
                    color: Colors.black,
                    fontSize: 10,
                    fontWeight: FontWeight.w400,
                  ),
                ),
              ),
            ),
          );
        }),
      ],
    );
  }
}
